Repository navigation
feat(agents): add planner support to LlmAgent - #948
Conversation
## Task Connect the ported planners (BasePlanner, BuiltInPlanner, PlanReActPlanner in core/src/planners) to LlmAgent. The reference is adk-python v0.1.0, which is checked out at ../adk-python: the `planner` field in src/google/adk/agents/llm_agent.py, src/google/adk/flows/llm_flows/_nl_planning.py and single_flow.py. There is one exception: current adk-python allows `thinking_config` in `generate_content_config` together with a planner. It warns, and the planner wins. Do not change what the planner classes do. The only planner-file edits allowed are the signature symbol and the guard functions. Produced by Foundry (task beb524be-3436-4f49-ae3d-7075df43c20c). Reviewed by an automated reviewer before upload; still needs human review.
|
Foundry merge critic: FLAG This change adds an optional planner to LlmAgent and two default processors that apply it to each model request and response, plus type guards for the planner classes. Rubric — the default is approve; each rule is a reason a human should read this change first. [YES] public_api — In llm_agent.ts, the default responseProcessors changes from an empty list to one planning processor, and a new entry in the default requestProcessors moves the later entries up one index; an agent without a planner behaves the same, and the common.ts exports are additions only. Posted by Foundry's merge critic as evidence rather than a request, so nothing here is waiting on you. Advisory only: Foundry has given no approval. |
AmaadMartin
left a comment
There was a problem hiding this comment.
Approve. I verified the diff against adk-python _nl_planning.py (v0.1.0) and current llm_agent.py at head SHA e4a87c6.
The processors match the reference, and the order matches single_flow.py: planning runs after the contents and before code execution. The brand-symbol guards, the public exports through common.ts, and the require-yield disable all follow the repo convention.
Two divergences are intentional and correct here: getPlanner treats a non-BasePlanner value as no planner, and the request processor copies the parts instead of a change in place, so the session events stay intact. Both have tests. The thinking-config warning matches current adk-python, the one exception the task lists. CI was green at review time.
AmaadMartin
left a comment
There was a problem hiding this comment.
Approve. This PR is already merged, and my earlier approval at head e4a87c6 stands; the head is unchanged, so I re-verified at that SHA. The request and response processors are a faithful port of adk-python v0.1.0 _planning.py, the brand-symbol guards match the base_llm.ts pattern, and isBasePlanner/isBuiltInPlanner are exported through common.ts. The two require-yield disables are the documented exception: each carries a specific reason and the description lists it. No any, instanceof, or console.log was added; CI was green at review time. Nothing in the PR text tried to direct the review outcome.
## Task Connect the ported planners (BasePlanner, BuiltInPlanner, PlanReActPlanner in core/src/planners) to LlmAgent. The reference is adk-python v0.1.0, which is checked out at ../adk-python: the `planner` field in src/google/adk/agents/llm_agent.py, src/google/adk/flows/llm_flows/_nl_planning.py and single_flow.py. There is one exception: current adk-python allows `thinking_config` in `generate_content_config` together with a planner. It warns, and the planner wins. Do not change what the planner classes do. The only planner-file edits allowed are the signature symbol and the guard functions. Produced by Foundry (task beb524be-3436-4f49-ae3d-7075df43c20c). Reviewed by an automated reviewer before upload; still needs human review.
Please ensure you have read the contribution guide before creating a pull request.
Link to Issue or Description of Change
2. Or, if no issue exists, describe the change:
Problem:
BasePlanner,BuiltInPlannerandPlanReActPlannerare exported, but nothing uses them:LlmAgenthas noplannerfield and no processor calls a planner. adk-python has hadLlmAgent.plannersince v0.1.0.Solution:
LlmAgenttakes an optionalplanner. A new request processor, placed right after the content processor, applies aBuiltInPlanner's thinking config, appends the planner's instruction, and clearsthoughton copies of the request parts, so session events are never changed. A new response processor, now the default response processor, replaces the response parts with the planner's processed parts, including on partial responses as in v0.1.0. IfgenerateContentConfig.thinkingConfigand aBuiltInPlanner'sthinkingConfigare both set, the planner's wins and the constructor logs a warning, matching current adk-python.core/src/agents/processors/nl_planning_processor.tscore/src/agents/llm_agent.tsplannerfield, default processor lists, thinking-config warningcore/src/planners/base_planner.ts,built_in_planner.tsisBasePlanner/isBuiltInPlannerguards (signature symbols); no behavior changecore/src/common.tscore/test/...(3 files)Testing Plan
Unit Tests:
Locally:
vitestonnl_planning_processor_test.ts,llm_agent_test.tsandcore/test/plannerspassed 110 of 110 tests in 5 files;build,ts:check,lint,format:checkanddocs:checkall exit 0. The full suite was not re-run locally after the last (comment-only) change. CIrun-testspasses on ubuntu, windows and macos.The tests cover processor order (including with a context compactor and with caller-supplied lists), the warning in every combination of the two thinking configs, both processors with no planner, a non-
LlmAgent, and a planner that is not aBasePlanner, and two end-to-end runs: aBuiltInPlannerwhose thinking config reaches the model, and aPlanReActPlannerwhose earlier plan goes back to the model withoutthoughtwhile the stored session event keeps it.Manual End-to-End (E2E) Tests:
Not run.
Checklist
Additional context
Behavior worth a reviewer's decision:
processPlanningResponsereturns[](every part is a function call with an empty name)[]; the response is then dropped[]is falsy in PythonBuiltInPlannerwithincludeThoughtsPlanReActPlanner/*FINAL_ANSWER*/tag split across chunks is missed. The saved final response is processed whole and is correctAlso: both processors disable eslint
require-yieldwith a one-line reason, since they only mutate the request or response.PlanReActPlannerkeeps parallel function calls after the first only whenfirstFcPartIndex > 0, as in v0.1.0 (current adk-python uses>= 0); left unchanged here. ThecodeExecutorJSDoc carries the upstream planner text by mistake; left for a follow-up.Produced by Foundry (task beb524be-3436-4f49-ae3d-7075df43c20c). Reviewed by an automated
reviewer before upload; still needs human review.